Option values topic
The values of the options. Dart has no union types, so each option TanStack Query types as "number, flag or function" is a small const sealed family here: StaleTime, GcTime, Enabled, RetryPolicy, RetryDelay, RefetchOn, RefetchInterval, NetworkMode, InitialData, PlaceholderData. "Off" is always a value of its own, never null.
Classes
- Enabled Option values
-
Whether a query may fetch on its own — the
enabledoption. - EnabledNo Option values
- The Enabled.no variant: the query never fetches on its own, but serves cached data and honours an explicit refetch.
- EnabledWhen Option values
-
The Enabled.when variant: enabled while predicate returns
truefor the query. - EnabledYes Option values
- The Enabled.yes variant: the query fetches on its own.
- GcTime Option values
-
How long a query nobody observes stays in the cache — the
gcTimeoption (the name is TanStack Query's: "garbage-collection time"). - GcTimeDuration Option values
- The GcTime.duration variant: collected duration after the query lost its last observer.
- GcTimeNever Option values
- The GcTime.never variant: an unobserved query stays cached until it is removed by hand or the client is cleared.
-
InitialData<
TQueryData> Option values - The value of QueryOptions.initialData: seed data written into the cache, as if it had been fetched.
-
InitialDataCompute<
TQueryData> Option values - The InitialData.compute variant: a seed computed lazily, for as long as the query has no data.
-
InitialDataValue<
TQueryData> Option values -
The InitialData.value variant: a seed that is always present, even when
data is
nullfor a nullable data type. -
PlaceholderData<
TQueryData> Option values - The value of QueryObserverOptionsBase.placeholderData: data an observer shows while its query has none of its own.
-
PlaceholderDataCompute<
TQueryData> Option values -
The PlaceholderData.compute variant: a placeholder computed from what
the observer showed last (TanStack Query:
placeholderData: (previousData, previousQuery) => value). -
PlaceholderDataKeepPrevious<
TQueryData> Option values -
The PlaceholderData.keepPrevious variant: while the observer's new key
has no data, it keeps showing what it showed for the key before, flagged
as
isPlaceholderData. Equal to every otherkeepPrevious()of its type, so options that use it compare equal across rebuilds. -
PlaceholderDataValue<
TQueryData> Option values - The PlaceholderData.value variant: a fixed placeholder, shown whenever the query has no data of its own.
- RefetchInterval Option values
-
Polling — the
refetchIntervaloption. - RefetchIntervalDynamic Option values
-
The RefetchInterval.dynamic variant: the interval is computed from the
query each time the timer is re-armed, and
nullstops polling. - RefetchIntervalEvery Option values
- The RefetchInterval.every variant: polls at a fixed interval.
- RefetchIntervalOff Option values
- The RefetchInterval.off variant: no polling.
- RefetchOn Option values
-
Whether an event refetches an observed query — the value of the
refetchOnMount,refetchOnWindowFocusandrefetchOnReconnectoptions. - RefetchOnAlways Option values
- The RefetchOn.always variant: the event refetches, fresh data or not.
- RefetchOnIfStale Option values
- The RefetchOn.ifStale variant: the event refetches stale data only.
- RefetchOnNever Option values
- The RefetchOn.never variant: the event never refetches.
- RefetchOnWhen Option values
- The RefetchOn.when variant: the answer is computed per query each time the event fires.
- RetryAlways Option values
- The RetryPolicy.always variant: retries until an attempt succeeds.
- RetryDelay Option values
-
How long to wait before the next attempt after a failure — the
retryDelayoption. Only consulted when RetryPolicy decided to retry. - RetryDelayDynamic Option values
- The RetryDelay.dynamic variant: every wait computed by a function of the failure count and the error.
- RetryDelayExponential Option values
-
The RetryDelay.exponential variant:
min(base * 2^failureCount, maximum). - RetryDelayFixed Option values
- The RetryDelay.fixed variant: the same wait before every retry.
- RetryNever Option values
- The RetryPolicy.never variant: the first failure is final.
- RetryPolicy Option values
-
Whether a failed attempt is tried again — the
retryoption. - RetryTimes Option values
-
The RetryPolicy.times variant: up to count retries, so at most
count + 1attempts. - RetryWhen Option values
-
The RetryPolicy.when variant: retries while predicate returns
true. - StaleTime Option values
-
How long fetched data counts as fresh — the
staleTimeoption. - StaleTimeDuration Option values
- The StaleTime.duration variant: fresh for duration after the fetch that produced the data, stale from then on.
- StaleTimeDynamic Option values
- The StaleTime.dynamic variant: a stale time computed from the query each time staleness is checked.
- StaleTimeInfinite Option values
- The StaleTime.infinite variant: never stale by time, so nothing refetches it on its own, but an invalidation or an explicit refetch still does — which is what separates it from StaleTimeStatic.
- StaleTimeStatic Option values
-
The StaleTime.static variant: never stale, and — while an observer with
this option holds the query — never refetched by a trigger either: not on
mount, focus, reconnect, invalidation or
refetchQueries.
Enums
- NetworkMode Option values
-
How connectivity gates fetching — the
networkModeoption, for queries and mutations alike. Connectivity comes from the client's OnlineManager.